<template>
    <div>
        <h2>信息显示</h2>
       
        <input type="button" value="导出" class="btn btn-info" @click="execport"/>

        <table class="table table-bordered">
            <tbody>

                <tr>
                    <td>用户账号</td>
                    <td>密码</td>
                    <td>联系方式</td>
                    <td>简介</td>
                    <td>状态</td>
                    <td>创建时间</td>
                </tr>

                <tr v-for="item in data.list" :key="item.Id">
                    <td>{{item.Name}}</td>
                    <td>{{item.Pwd}}</td>
                    <td>{{item.Phone}}</td>
                    <td>{{item.Desc}}</td>
                    <td>{{item.Stare? "可用":"禁用"}}</td>
                    <td>{{item.CreateTime}}</td>
                </tr>

            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
import {useUserStore} from '@/stores/user'

let router = useRouter();
let route = useRoute();

const a = useUserStore();


let list:any=reactive({
    PageIdenx:1,
    PageSizer:2,
    Name:''
})

let data:any=reactive({
   list:[],
   totaCount:0,
   totaPage:0
})

onMounted(()=>{
    if(a.userInfo.Id)
    {
        showall();
    }
    else
    {
        router.push('/admin')
    }
    
})

const showall = ()=>{
    axios({
        url:'http://localhost:5187/api/Admin/AddShow',
        method:'get',
        params:list
    })
    .then((res)=>{
        Object.assign(data,res.data);
    })
    .catch((err)=>{
        console.log(err);
    })
}

const execport = ()=>{
    location.href = `http://localhost:5187/api/Admin/Execport?PageIdenx=${list.PageIdenx}&PageSizer=${list.PageSizer}&Name=${list.Name}`
}


</script>

<style scoped>

</style>